@burtson-labs/bandit-engine 2.0.148 → 2.0.149
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chat-N2KBORSG.mjs → chat-Z4SQGSMN.mjs} +2 -2
- package/dist/{chunk-NCZX5YKN.mjs → chunk-ANX33XAO.mjs} +72 -1
- package/dist/chunk-ANX33XAO.mjs.map +1 -0
- package/dist/{chunk-3ADU3BFL.mjs → chunk-JQSZNGII.mjs} +2 -2
- package/dist/index.js +71 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/management/management.js +71 -0
- package/dist/management/management.js.map +1 -1
- package/dist/management/management.mjs +1 -1
- package/package.json +1 -1
- package/dist/chunk-NCZX5YKN.mjs.map +0 -1
- /package/dist/{chat-N2KBORSG.mjs.map → chat-Z4SQGSMN.mjs.map} +0 -0
- /package/dist/{chunk-3ADU3BFL.mjs.map → chunk-JQSZNGII.mjs.map} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
chat_default
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-ANX33XAO.mjs";
|
|
4
4
|
import "./chunk-ONQMRE2G.mjs";
|
|
5
5
|
import "./chunk-P5IJLX6I.mjs";
|
|
6
6
|
import "./chunk-K2JGFKEB.mjs";
|
|
@@ -13,4 +13,4 @@ import "./chunk-BJTO5JO5.mjs";
|
|
|
13
13
|
export {
|
|
14
14
|
chat_default as default
|
|
15
15
|
};
|
|
16
|
-
//# sourceMappingURL=chat-
|
|
16
|
+
//# sourceMappingURL=chat-Z4SQGSMN.mjs.map
|
|
@@ -4287,6 +4287,10 @@ ${protocol}`;
|
|
|
4287
4287
|
/\b(?:web_search|web_fetch|image_generation|create_file|ask_user)\s*\(/
|
|
4288
4288
|
);
|
|
4289
4289
|
if (callIdx !== -1) t = t.slice(0, callIdx);
|
|
4290
|
+
const jsonIdx = t.search(
|
|
4291
|
+
/\{\s*"name"\s*:\s*"(?:web_search|web_fetch|image_generation|create_file|ask_user)"/
|
|
4292
|
+
);
|
|
4293
|
+
if (jsonIdx !== -1) t = t.slice(0, jsonIdx);
|
|
4290
4294
|
t = t.replace(/```[\w-]*\s*$/, "");
|
|
4291
4295
|
const fenceCount = (t.match(/```/g) || []).length;
|
|
4292
4296
|
if (fenceCount % 2 === 1) t = t.slice(0, t.lastIndexOf("```"));
|
|
@@ -4352,6 +4356,9 @@ ${protocol}`;
|
|
|
4352
4356
|
const visibleMessage = stripThinking(fullMessage);
|
|
4353
4357
|
const bareToolMatch = visibleMessage.match(
|
|
4354
4358
|
/\b(web_search|web_fetch|image_generation|create_file|ask_user)\s*\(/
|
|
4359
|
+
) || // JSON-form calls from cloud/native-tool engines.
|
|
4360
|
+
visibleMessage.match(
|
|
4361
|
+
/\{\s*"name"\s*:\s*"(web_search|web_fetch|image_generation|create_file|ask_user)"/
|
|
4355
4362
|
);
|
|
4356
4363
|
if (/```(?:tool_code|TOOL_CODE)/.test(visibleMessage) || bareToolMatch) {
|
|
4357
4364
|
sawToolBlock = true;
|
|
@@ -4479,6 +4486,70 @@ ${fn}(${argStr})
|
|
|
4479
4486
|
}
|
|
4480
4487
|
return out;
|
|
4481
4488
|
};
|
|
4489
|
+
const bridgeJsonToolBlobs = (message) => {
|
|
4490
|
+
const KNOWN = ["web_search", "web_fetch", "image_generation", "create_file", "ask_user", "ask-user"];
|
|
4491
|
+
const re = new RegExp(`\\{\\s*"name"\\s*:\\s*"(${KNOWN.join("|")})"`, "g");
|
|
4492
|
+
const spans = [];
|
|
4493
|
+
let m;
|
|
4494
|
+
while ((m = re.exec(message)) !== null) {
|
|
4495
|
+
let depth = 0;
|
|
4496
|
+
let i = m.index;
|
|
4497
|
+
let inStr = false;
|
|
4498
|
+
let esc = false;
|
|
4499
|
+
for (; i < message.length; i++) {
|
|
4500
|
+
const ch = message[i];
|
|
4501
|
+
if (esc) {
|
|
4502
|
+
esc = false;
|
|
4503
|
+
continue;
|
|
4504
|
+
}
|
|
4505
|
+
if (ch === "\\") {
|
|
4506
|
+
esc = true;
|
|
4507
|
+
continue;
|
|
4508
|
+
}
|
|
4509
|
+
if (ch === '"') {
|
|
4510
|
+
inStr = !inStr;
|
|
4511
|
+
continue;
|
|
4512
|
+
}
|
|
4513
|
+
if (inStr) continue;
|
|
4514
|
+
if (ch === "{") depth++;
|
|
4515
|
+
else if (ch === "}") {
|
|
4516
|
+
depth--;
|
|
4517
|
+
if (depth === 0) {
|
|
4518
|
+
i++;
|
|
4519
|
+
break;
|
|
4520
|
+
}
|
|
4521
|
+
}
|
|
4522
|
+
}
|
|
4523
|
+
const blob = message.slice(m.index, i);
|
|
4524
|
+
try {
|
|
4525
|
+
const parsed = JSON.parse(blob);
|
|
4526
|
+
const args = parsed.arguments ?? parsed.parameters ?? parsed.input ?? {};
|
|
4527
|
+
let start = m.index;
|
|
4528
|
+
let end = i;
|
|
4529
|
+
const fenceOpen = message.slice(0, start).match(/```[a-zA-Z0-9_-]*[ \t]*\n[ \t]*$/);
|
|
4530
|
+
if (fenceOpen) {
|
|
4531
|
+
start -= fenceOpen[0].length;
|
|
4532
|
+
const fenceClose = message.slice(end).match(/^[ \t]*\n?```/);
|
|
4533
|
+
if (fenceClose) end += fenceClose[0].length;
|
|
4534
|
+
}
|
|
4535
|
+
spans.push({
|
|
4536
|
+
start,
|
|
4537
|
+
end,
|
|
4538
|
+
fn: parsed.name,
|
|
4539
|
+
args: typeof args === "string" ? args : JSON.stringify(args)
|
|
4540
|
+
});
|
|
4541
|
+
} catch {
|
|
4542
|
+
}
|
|
4543
|
+
re.lastIndex = i;
|
|
4544
|
+
}
|
|
4545
|
+
let result = message;
|
|
4546
|
+
for (let k = spans.length - 1; k >= 0; k--) {
|
|
4547
|
+
const s = spans[k];
|
|
4548
|
+
result = result.slice(0, s.start) + "\n```tool_code\n" + s.fn + "(" + s.args + ")\n```\n" + result.slice(s.end);
|
|
4549
|
+
}
|
|
4550
|
+
return result;
|
|
4551
|
+
};
|
|
4552
|
+
fullMessage = bridgeJsonToolBlobs(fullMessage);
|
|
4482
4553
|
const toolCallMatches = extractToolCalls(fullMessage);
|
|
4483
4554
|
let enhancedMessage = fullMessage;
|
|
4484
4555
|
const summarizableResults = [];
|
|
@@ -11473,4 +11544,4 @@ var chat_default = Chat;
|
|
|
11473
11544
|
export {
|
|
11474
11545
|
chat_default
|
|
11475
11546
|
};
|
|
11476
|
-
//# sourceMappingURL=chunk-
|
|
11547
|
+
//# sourceMappingURL=chunk-ANX33XAO.mjs.map
|